<@ms.html5>
     <@ms.nav title="商品属性增加" back=true>
        <@ms.saveButton  onclick="save()"/>
    </@ms.nav>
    <@ms.panel>
        <@ms.form name="articleForm" isvalidation=true>
            <@ms.hidden name="companyId" value="${company.companyId?default(0)}"/>
            <@ms.text name="companyName" colSm="2" width="200" label="公司名称"    title="公司名称" size="5"  placeholder="请输入公司名称"  value="${company.companyName?default('')}"  validation={"maxlength":"20","required":"true", "data-bv-notempty-message":"公司名称不能为空","data-bv-stringlength-message":"属性名称在20个字符以内!"}/>
            <@ms.text name="companySort" colSm="2" width="200" label="公司排序"    title="公司排序" size="5"  placeholder="请输入公司排序"  value="${company.companySort?default(0)}" />
            <@ms.formRow colSm="2" label="保险公司LOGO图" width="400" >
					<@ms.uploadImg path="" uploadFloderPath="company" inputName="companyLogo" size="1" msg="提示:保险公司缩略图,支持jpg格式"  imgs="${company.companyLogo?default('a.png')}"    />
			</@ms.formRow>
			<@ms.text name="linkman" colSm="2" width="200" label="联系人"    title="联系人" size="5"  placeholder="请输入联系人"  value="${company.linkman?default('')}"  />
			<@ms.text name="mobile" colSm="2" width="200" label="联系电话"    title="联系电话" size="5"  placeholder="请输入联系电话"  value="${company.mobile?default('')}"  />
        	<@ms.editor colSm="2" name="introduction" label="公司介绍" content="${company.introduction?default('')}" />
        
        </@ms.form>
    </@ms.panel>
</@ms.html5>
<script>
    var url = "${managerPath}/goods/company/save.do";
    if($("input[name = 'companyId']").val() > 0){
        url = "${managerPath}/goods/company/update.do";
        $(".btn-success").text("更新");
    }
    //编辑按钮onclick
    function save() {
        $("#articleForm").data("bootstrapValidator").validate();
            var isValid = $("#articleForm").data("bootstrapValidator").isValid();
            if(!isValid) {
                <@ms.notify msg= "数据提交失败，请检查数据格式！" type= "warning" />
                return;
        }
        var btnWord =$(".btn-success").text();
        $(".btn-success").text(btnWord+"中...");
        $(".btn-success").prop("disabled",true);
       
        $.ajax({
            type:"post",
            dataType:"json",
            data:$("form[name = 'articleForm']").serialize(),
            url:url,
            success: function(status) {
            	debugger;
                if(status.result == true) { 
                    <@ms.notify msg="保存或更新成功" type= "success" />
                    location.href = "${managerPath}/goods/company/index.do";
                }
                else{
                    <@ms.notify msg= "保存或更新失败！值不合规则"  type= "fail" />
                    location.href= "${managerPath}/goods/company/index.do";
                }
            }
        })
    }    
</script>